home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Utilitare / emu / Emu8086_Setup_307c.exe / {app} / Samples / micro-os_loader.asm < prev    next >
Encoding:
Assembly Source File  |  2002-08-02  |  2.3 KB  |  120 lines

  1. ; This is a very basic example
  2. ; of a tiny Operating System.
  3.  
  4. ; Directive to create BOOT file:
  5.    #MAKE_BOOT#
  6.  
  7. ; This is an OS loader only!
  8. ;
  9. ; It can be loaded at the first
  10. ; sector of a floppy disk:
  11. ;   cylinder: 0
  12. ;   sector: 1
  13. ;   head: 0
  14. ;
  15. ; The code in this file is supposed
  16. ; to load the Kernel (micro-os_kernel.asm)
  17. ; and to pass control over it.
  18. ; The Kernel code should be on floppy at:
  19. ;   cylinder: 0
  20. ;   sector: 2
  21. ;   head: 0
  22.  
  23. ; Memory table (hex):
  24. ; -------------------------------
  25. ; 07C0:0000 |   Boot Sector
  26. ; 07C0:01FF |   (512 bytes)
  27. ; -------------------------------
  28. ; 07C0:0200 |    Stack
  29. ; 07C0:03FF |   (255 words)
  30. ; -------------------------------
  31. ; 0800:0000 |    Kernel
  32. ; 0800:1400 | 
  33. ;           |   (currently 5 Kb,
  34. ;           |    10 sectors are
  35. ;           |    loaded from
  36. ;           |    floppy)
  37. ; -------------------------------
  38.  
  39. ; micro-os_loader.asm file produced by
  40. ; this code should be less or
  41. ; equal to 512 bytes, since this
  42. ; is the size of the boot
  43. ; sector!
  44. ; Current version is compiled to
  45. ; 101 bytes.
  46.  
  47.  
  48. include 'emu8086.inc'
  49.  
  50. ; Boot record is loaded at 0000:7C00
  51. ORG 7C00h
  52.  
  53. ; skip the data section:
  54. JMP start
  55.  
  56. ;==== data section =====================
  57.  
  58. ; welcome message:
  59. msg  DB 'Welcome to micro-os', 13, 10,
  60.      DB 'Loading...', 0
  61.  
  62. ;======================================
  63.  
  64. start:
  65.  
  66. ; initialize the stack:
  67. MOV     AX, 07C0h
  68. MOV     SS, AX
  69. MOV     SP, 03FEh ; top of the stack.
  70.  
  71.  
  72. ; set Data Segment:
  73. PUSH    CS
  74. POP     DS
  75.  
  76. ; set default video mode 80x25:
  77. MOV     AH, 00h
  78. MOV     AL, 03h
  79. INT     10h
  80.  
  81. ; print welcome message:
  82. LEA     SI, msg
  83. CALL    print_string
  84.  
  85. ;===================================
  86. ; load the Kernel at 0800h:0000h
  87. ; 10 sectors starting at:
  88. ;   cylinder: 0
  89. ;   sector: 2
  90. ;   head: 0
  91.  
  92. ; BIOS passes drive number in DL,
  93. ; so it's not changed:
  94.  
  95. MOV     AH, 02h ; read function.
  96. MOV     AL, 10  ; sectors to read.
  97. MOV     CH, 0   ; cylinder.
  98. MOV     CL, 2   ; sector.
  99. MOV     DH, 0   ; head.
  100. ; DL not changed! - drive number.
  101.  
  102. ; ES:BX points to receiving
  103. ;  data buffer:
  104. MOV     BX, 0800h   
  105. MOV     ES, BX
  106. MOV     BX, 0
  107.  
  108. ; read!
  109. INT     13h
  110. ;===================================
  111.  
  112. ; pass control to Kernel:
  113. JMP     0800h:0000h
  114.  
  115. ;===========================================
  116.  
  117. DEFINE_PRINT_STRING
  118.  
  119. END
  120.